import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/home',
      component: () => import('@/views/HomeView.vue')
    },
    {
      name: 'search',
      path: '/search/:keyword?',
      component: () => import('@/views/SearchView.vue')
    },
    {
      name: 'my',
      path: '/my',
      component: () => import('@/views/MyView.vue')
    },
    {
      name: 'detail',
      path: '/detail/:id?',
      component: () => import('@/views/ArticleDetail.vue')
    },
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'NotFound',
      component: () => import('@/views/NotFound.vue')
    } //最后一个
  ]
})

export default router
